<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
    <title>注册</title>
    <link rel="stylesheet" href="css/aui.css" />
    <link rel="stylesheet" href="./css/index.css">
    <link rel="stylesheet" href="css/style.css" />
	<link rel="stylesheet" href="js/layer/need/layer.css">
</head>
<body class="bg-register">
    <div class="register-contain">
        <header class="aui-bar aui-bar-nav aui-background-transparent aui-position-fixed aui-bar-nav-search aui-text-default">
			<a class="aui-pull-left aui-btn" href="JavaScript:history.go(-1)">
				<span class="aui-iconfont aui-icon-left aui-text-white aui-font-size-14"></span>
			</a>
			<div class="aui-title aui-font-weight aui-text-white title aui-font-size-16">
				注册
			</div>
		</header>
        <div class="form-group">
            <div class="form-item">
                <label for="phone">
                    <img src="images/phone.png" alt="">
                </label>
                <input id="username" type="text" placeholder="请输入手机号">
            </div>
           <!-- <div class="form-item">
                <label for="code">
                    <img src="images/code.png" alt="">
                </label>
                <input id="code" type="text" placeholder="请输入验证码">
                <button>发送验证码</button>
            </div> -->
            <div class="form-item">
                <label for="password">
                    <img src="images/key.png" alt="">
                </label>
                <input id="password" type="password" placeholder="请填写密码">
            </div>
            <div class="form-item">
                <label for="respassword">
                    <img src="images/key.png" alt="">
                </label>
                <input id="respassword" type="password" placeholder="请确认密码">
            </div>
        </div>
        <div class="button-group">
            <button class="login-btn" onclick="register()">注册</button>
        </div>
        <div class="authorization">
            <input type="checkbox" checked="checked">
            <span class="ml-5">注册使用即表示同意</span>
            <span class="protocol">用户协议及版权声明</span>
        </div>
        <div class="go-login">
            <a href="login.html">已经有账号？去登录</a>
        </div>
        <!-- <div class="tourism">
            <img src="images/tourism.png" alt="">
            <img src="images/tourism2.png" alt="">
            <img src="images/tourism3.png" alt="">
        </div> -->
    </div>

<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/layer/layer.js"></script>
<script type="text/javascript">
	var baseurl = 'http://kt.zhangzhengjiang.top/api/';
	function register(){
		var username = $('#username').val();
		var password = $('#password').val();
		var respassword = $('#respassword').val();
		if (username&&password&&respassword) {
			if (password == respassword) {
				$.ajax({
					url:baseurl+'user/register',
					type:'post',
					data:{username:username,password:password,mobile:username},
					success:function(res){
						if(res.code == 1){
						  layer.open({
							content: '注册成功'
							,skin: 'msg'
							,time: 2 ,//2秒后自动关闭
							success: function(elem){
							  window.location.href='./login.html';
							}    
						  });
						}else{
							layer.open({
								content: res.msg
								,skin: 'msg'
								,time: 2 ,//2秒后自动关闭
								
							});
						}
					}
				})
			}
			
		}else{
			layer.open({
				content: '请完善信息后提交'
				,skin: 'msg'
				,time: 2 ,//2秒后自动关闭
				
			});
		}
	}
</script>
</body>
</html>
